#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

#define MAX_WORDS 1000   
#define MAX_LEN 21       

typedef struct {
    char word[MAX_LEN];
    int count;
} WordEntry;

WordEntry entries[MAX_WORDS];
int entry_count = 0;


void add_word(const char *word) {
    if (strlen(word) == 0) return;

  
    for (int i = 0; i < entry_count; i++) {
        if (strcmp(entries[i].word, word) == 0) {
            entries[i].count++;
            return;
        }
    }


    if (entry_count < MAX_WORDS) {
        strcpy(entries[entry_count].word, word);
        entries[entry_count].count = 1;
        entry_count++;
    }
}


void process_word(char *word) {
    char *apos = strchr(word, '\'');
    if (apos) {
        if (strcmp(apos, "'re") == 0) {
            *apos = '\0';
            add_word(word);
            add_word("are");
            return;
        } else if (strcmp(apos, "'m") == 0) {
            *apos = '\0';
            add_word(word);
            add_word("am");
            return;
        } else if (strcmp(apos, "'s") == 0) {
            *apos = '\0';
            add_word(word);
            add_word("is");
            return;
        }
    }
    add_word(word);
}

int compare(const void *a, const void *b) {
    return strcmp(((WordEntry*)a)->word, ((WordEntry*)b)->word);
}

int main() {
    char buffer[10000]; 
    int c, idx = 0;
    
  
    while ((c = getchar()) != EOF && c != '#') {
        buffer[idx++] = tolower(c);
    }
    buffer[idx] = '\0';

    char *p = buffer;
    while (*p) {
    
        while (*p && (isspace(*p) || strchr(",?.!", *p))) p++;
        if (!*p) break;


        char word[MAX_LEN] = {0};
        int i = 0;
        while (i < MAX_LEN-1 && (*p == '\'' || isalpha(*p))) {
            word[i++] = *p++;
        }
        word[i] = '\0';
        
        process_word(word);
    }


    qsort(entries, entry_count, sizeof(WordEntry), compare);
    printf("%d\n", entry_count);
    for (int i = 0; i < entry_count; i++) {
        printf("%s %d\n", entries[i].word, entries[i].count);
    }
    return 0;
}
